package com.sumainfor.pc.market.controller.rentadviser;

import com.sumainfor.common.util.JsonResult;
import com.sumainfor.pc.market.service.RdActivityService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.io.Serializable;
import java.util.Map;

/**
 * 活动
 */
@RestController
@RequestMapping("/tenant/key/rentadviser/RdWxActivity")
public class RdWxActivityController implements Serializable {
    @Autowired
    private RdActivityService rdActivityService;
    /**
     * 根据房源编号查询活动优惠之后的价格
     */
    @PostMapping("/getOptimalActivity")
    public JsonResult getOptimalActivity(@RequestBody Map<String,Object> params){
        JsonResult result=new JsonResult();
        if(params.get("LeaseTerm")==null || params.get("PayType")==null || params.get("PaMonthPrice")==null
        || params.get("HouInfoId")==null || params.get("PayTypeList")==null){
            return result.putFailed("缺少参数");
        }
        Map<String,Object> map=rdActivityService.getOptimalActivity(params);
        if (map!=null){
            result.put(map);
        }else{
            result.putFailed("服务器繁忙");
        }
        return result;
    }
}
